package com.winning.yanghao.designpattern.singleton.register;

import com.winning.yanghao.designpattern.factory.AppleComputer;
import com.winning.yanghao.designpattern.factory.Computer;
import com.winning.yanghao.designpattern.singleton.lazy.LazyOne;

import java.util.concurrent.CountDownLatch;

public class BeanFactoryTest {

    public static void main(String[] args) {
        final int count = 200;
        final CountDownLatch countDownLatch = new CountDownLatch(count);
        for(int i=0; i<count; i++){
            new Thread(){

                @Override
                public void run() {
                    try {
                        countDownLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    AppleComputer computer = (AppleComputer) BeanFactory.getInstance("com.winning.yanghao.designpattern.factory.AppleComputer");
                    System.out.println(computer);
                }

            }.start();
            countDownLatch.countDown();
        }
    }

}
